<?php
/**
 * Created by PhpStorm.
 * User: 低调
 * Date: 2018/5/25
 * Time: 16:47
 */
include("../connectdb.php");
include("head.php");
session_start();
$id = $_SESSION['id'];
$sql = "SELECT * FROM normalUser WHERE id='$id'";
$result = mysqli_fetch_array(mysqli_query($conn,$sql));
if(isset($_POST['submit'])){
    $username = $_POST['username'];
    $email = $_POST['email'];
    $sex = $_POST['sex'];
    $age = $_POST['age'];
    $info =$_POST['info'];
    $sql = "UPDATE normalUser SET `username`='$username',`email`='$email',`sex`='$sex',`age`='$age',`info`='$info' WHERE id='$id'";
    if(mysqli_query($conn,$sql)){
        echo "<script>alert('信息修改成功');location.href='index.php'</script>";
    }
    else
        echo "<script>alert('信息修改失败');history.go(-1);</script>";
}
?>
<!-- 内容区域 -->
<div class="tpl-content-wrapper">

    <div class="row-content am-cf">
        <div class="row">

            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <div class="widget am-cf">
                    <div class="widget-head am-cf">
                        <div class="widget-title am-fl">个人信息</div>
                        <div class="widget-function am-fr">
                            <a href="javascript:;" class="am-icon-cog"></a>
                        </div>
                    </div>
                    <div class="widget-body am-fr">

                        <form class="am-form tpl-form-border-form tpl-form-border-br" action="" method="post">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">姓名 <span class="tpl-form-line-small-title">Name</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input" id="user-name" name="username" placeholder="输入姓名或昵称" value="<?php echo $result['username'];?>">
                                    <small>可填你喜欢的昵称</small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">邮箱 <span class="tpl-form-line-small-title">Title</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="tpl-form-input" id="user-name" name="email" placeholder="请输入登录邮箱" value="<?php echo $result['email'];?>">
                                    <small>邮箱为必填</small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="doc-select-1" class="am-u-sm-3 am-form-label">性别 <span class="tpl-form-line-small-title">Sex</span></label>
                                <div class="am-u-sm-9">
                                    <label class="am-radio-inline">
                                        <input name="sex" <?php if($result['sex']=='男') echo'checked';?> type="radio" value="男" class="col-sm-6">
                                        男
                                    </label>
                                    <label class="am-radio-inline">
                                        <input name="sex" <?php if($result['sex']=='女') echo'checked';?> type="radio" value="女" class="col-sm-6">
                                        女
                                    </label>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="user-email" class="am-u-sm-3 am-form-label">出生日期 <span class="tpl-form-line-small-title">Birth</span></label>
                                <div class="am-u-sm-9">
                                    <input type="text" class="am-form-field tpl-form-no-bg" placeholder="出生日期" name="age" value="<?php echo $result['age'];?>" data-am-datepicker="" readonly="">
                                    <small>出生日期</small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="user-intro" class="am-u-sm-3 am-form-label">个人信息</label>
                                <div class="am-u-sm-9">
                                    <textarea class="" rows="10" id="user-intro" name="info" placeholder="请输入个人信息"><?php echo $result['info'];?></textarea>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3">
                                    <button type="submit" name="submit" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
